home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1998 June / Cd Pc Users 9.iso / prog / inst / anictl / demo / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-14  |  15.2 KB  |  431 lines

  1. VERSION 5.00
  2. Object = "{E112F284-62AB-11D1-A1FA-00C0DFE045F2}#1.2#0"; "ccrpani.ocx"
  3. Begin VB.Form frmMain 
  4.    Caption         =   "CCRP Animation Control Demo"
  5.    ClientHeight    =   6948
  6.    ClientLeft      =   48
  7.    ClientTop       =   336
  8.    ClientWidth     =   7032
  9.    ClipControls    =   0   'False
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6948
  12.    ScaleWidth      =   7032
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.CommandButton cmdEnd 
  15.       Caption         =   "End"
  16.       Height          =   432
  17.       Left            =   2280
  18.       TabIndex        =   21
  19.       Top             =   6420
  20.       Width           =   2232
  21.    End
  22.    Begin VB.Frame fra 
  23.       Caption         =   "Events"
  24.       ForeColor       =   &H00C00000&
  25.       Height          =   1572
  26.       Index           =   3
  27.       Left            =   300
  28.       TabIndex        =   19
  29.       Top             =   3600
  30.       Width           =   6372
  31.       Begin VB.CommandButton cmdClearEvents 
  32.          Caption         =   "Clear List"
  33.          Height          =   432
  34.          Left            =   4920
  35.          TabIndex        =   13
  36.          ToolTipText     =   "Clears the event history"
  37.          Top             =   960
  38.          Width           =   1332
  39.       End
  40.       Begin VB.CheckBox chkOtherEvents 
  41.          Caption         =   "Other Events"
  42.          ForeColor       =   &H00000080&
  43.          Height          =   252
  44.          Left            =   4860
  45.          TabIndex        =   12
  46.          ToolTipText     =   "Sets whether or not non-mouse events are added to the event history."
  47.          Top             =   600
  48.          Value           =   1  'Checked
  49.          Width           =   1452
  50.       End
  51.       Begin VB.CheckBox chkMouseEvents 
  52.          Caption         =   "Mouse Events"
  53.          ForeColor       =   &H00000080&
  54.          Height          =   252
  55.          Left            =   4860
  56.          TabIndex        =   11
  57.          ToolTipText     =   "Sets whether or not mouse events are added to the event history."
  58.          Top             =   300
  59.          Value           =   1  'Checked
  60.          Width           =   1452
  61.       End
  62.       Begin VB.ListBox lstEvents 
  63.          Height          =   1200
  64.          ItemData        =   "frmMain.frx":0000
  65.          Left            =   120
  66.          List            =   "frmMain.frx":0002
  67.          TabIndex        =   10
  68.          ToolTipText     =   "Displays a history of events raised by the Animation control"
  69.          Top             =   240
  70.          Width           =   4632
  71.       End
  72.    End
  73.    Begin Animation.ccrpAnimation ccrpAnimation 
  74.       Height          =   1752
  75.       Left            =   300
  76.       Top             =   120
  77.       Width           =   6372
  78.       _ExtentX        =   11240
  79.       _ExtentY        =   3090
  80.       AutoOpen        =   0   'False
  81.       BackColor       =   -2147483644
  82.       BorderStyle     =   0
  83.       Center          =   -1  'True
  84.    End
  85.    Begin VB.Frame fra 
  86.       Caption         =   "Information"
  87.       ForeColor       =   &H00C00000&
  88.       Height          =   1092
  89.       Index           =   2
  90.       Left            =   300
  91.       TabIndex        =   17
  92.       Top             =   5220
  93.       Width           =   6372
  94.       Begin VB.Label lblInfo 
  95.          Caption         =   $"frmMain.frx":0004
  96.          ForeColor       =   &H000000FF&
  97.          Height          =   612
  98.          Left            =   180
  99.          TabIndex        =   18
  100.          Top             =   300
  101.          Width           =   6072
  102.          WordWrap        =   -1  'True
  103.       End
  104.    End
  105.    Begin VB.Frame fra 
  106.       Caption         =   "AVI"
  107.       ForeColor       =   &H00C00000&
  108.       Height          =   1632
  109.       Index           =   0
  110.       Left            =   3540
  111.       TabIndex        =   16
  112.       Top             =   1920
  113.       Width           =   3132
  114.       Begin VB.ComboBox cboAVI 
  115.          Height          =   288
  116.          HelpContextID   =   9
  117.          ItemData        =   "frmMain.frx":00D4
  118.          Left            =   180
  119.          List            =   "frmMain.frx":0100
  120.          TabIndex        =   6
  121.          ToolTipText     =   "The animation to play"
  122.          Top             =   600
  123.          Width           =   2472
  124.       End
  125.       Begin VB.CommandButton cmdPlay 
  126.          Caption         =   "Play"
  127.          Enabled         =   0   'False
  128.          Height          =   372
  129.          HelpContextID   =   15
  130.          Left            =   1620
  131.          TabIndex        =   9
  132.          ToolTipText     =   "Plays the animation"
  133.          Top             =   1020
  134.          Width           =   1212
  135.       End
  136.       Begin VB.CommandButton cmdOpen 
  137.          Caption         =   "Open"
  138.          Enabled         =   0   'False
  139.          Height          =   372
  140.          HelpContextID   =   11
  141.          Left            =   240
  142.          TabIndex        =   8
  143.          ToolTipText     =   "Opens the animation"
  144.          Top             =   1020
  145.          Width           =   1212
  146.       End
  147.       Begin VB.CommandButton cmdBrowse 
  148.          Caption         =   "..."
  149.          BeginProperty Font 
  150.             Name            =   "MS Sans Serif"
  151.             Size            =   9.6
  152.             Charset         =   0
  153.             Weight          =   400
  154.             Underline       =   0   'False
  155.             Italic          =   0   'False
  156.             Strikethrough   =   0   'False
  157.          EndProperty
  158.          Height          =   252
  159.          Left            =   2760
  160.          TabIndex        =   7
  161.          ToolTipText     =   "Browse for an AVI file"
  162.          Top             =   660
  163.          Width           =   270
  164.       End
  165.       Begin VB.CheckBox chkAutoPlay 
  166.          Caption         =   "AutoPlay"
  167.          ForeColor       =   &H00000080&
  168.          Height          =   252
  169.          HelpContextID   =   2
  170.          Left            =   180
  171.          TabIndex        =   5
  172.          ToolTipText     =   "Sets whether the AVI starts playing automatically once it is loaded."
  173.          Top             =   240
  174.          Value           =   1  'Checked
  175.          Width           =   2832
  176.       End
  177.    End
  178.    Begin VB.Frame fra 
  179.       Caption         =   "Styles"
  180.       ForeColor       =   &H00FF0000&
  181.       Height          =   1632
  182.       Index           =   1
  183.       Left            =   300
  184.       TabIndex        =   14
  185.       Top             =   1920
  186.       Width           =   3132
  187.       Begin VB.ComboBox cbo3DEffect 
  188.          Height          =   288
  189.          ItemData        =   "frmMain.frx":0169
  190.          Left            =   1260
  191.          List            =   "frmMain.frx":0176
  192.          Style           =   2  'Dropdown List
  193.          TabIndex        =   3
  194.          ToolTipText     =   "Sets the appearance with which the animation control is drawn"
  195.          Top             =   840
  196.          Width           =   1632
  197.       End
  198.       Begin VB.CheckBox chkCenter 
  199.          Caption         =   "Center"
  200.          ForeColor       =   &H00000080&
  201.          Height          =   192
  202.          HelpContextID   =   6
  203.          Left            =   1500
  204.          TabIndex        =   2
  205.          ToolTipText     =   "Sets whether the animation is centered in the control"
  206.          Top             =   300
  207.          Value           =   1  'Checked
  208.          Width           =   1452
  209.       End
  210.       Begin VB.CheckBox chkBorder 
  211.          Caption         =   "Border"
  212.          ForeColor       =   &H00000080&
  213.          Height          =   192
  214.          Left            =   180
  215.          TabIndex        =   0
  216.          ToolTipText     =   "Sets whether a black border is drawn around the control"
  217.          Top             =   300
  218.          Width           =   1212
  219.       End
  220.       Begin VB.CheckBox chkTransparent 
  221.          Caption         =   "Transparent"
  222.          ForeColor       =   &H00000080&
  223.          Height          =   192
  224.          HelpContextID   =   5
  225.          Left            =   180
  226.          TabIndex        =   1
  227.          ToolTipText     =   "Sets whether the control is transparent or whether the background colour from the animation is used."
  228.          Top             =   540
  229.          Value           =   1  'Checked
  230.          Width           =   2712
  231.       End
  232.       Begin VB.ComboBox cboTimer 
  233.          Enabled         =   0   'False
  234.          ForeColor       =   &H00000000&
  235.          Height          =   288
  236.          HelpContextID   =   20
  237.          ItemData        =   "frmMain.frx":0190
  238.          Left            =   1260
  239.          List            =   "frmMain.frx":019A
  240.          Style           =   2  'Dropdown List
  241.          TabIndex        =   4
  242.          ToolTipText     =   "Sets the method of synchronisation used whilst playing the animation (IE3+ version of COMCTL32.DLL only)"
  243.          Top             =   1200
  244.          Width           =   1632
  245.       End
  246.       Begin VB.Label lbl 
  247.          Caption         =   "Appearance:"
  248.          ForeColor       =   &H00000080&
  249.          Height          =   192
  250.          Index           =   1
  251.          Left            =   180
  252.          TabIndex        =   20
  253.          Top             =   900
  254.          Width           =   1032
  255.       End
  256.       Begin VB.Label lbl 
  257.          Caption         =   "Timer Type:"
  258.          ForeColor       =   &H00000080&
  259.          Height          =   192
  260.          Index           =   0
  261.          Left            =   180
  262.          TabIndex        =   15
  263.          Top             =   1260
  264.          Width           =   972
  265.       End
  266.    End
  267. Attribute VB_Name = "frmMain"
  268. Attribute VB_GlobalNameSpace = False
  269. Attribute VB_Creatable = False
  270. Attribute VB_PredeclaredId = True
  271. Attribute VB_Exposed = False
  272. Option Explicit
  273. Private Sub cbo3DEffect_Click()
  274.   ccrpAnimation.Appearance = cbo3DEffect.ItemData(cbo3DEffect.ListIndex)
  275. End Sub
  276. Private Sub cboAVI_Change()
  277.   On Error Resume Next
  278.   If ccrpAnimation.Status > aniEmpty Then ccrpAnimation.CloseAVI
  279.   cmdOpen.Enabled = cboAVI.Text > ""
  280.   cmdPlay.Enabled = cboAVI.Text > ""
  281. End Sub
  282. Private Sub cboAVI_Click()
  283.   cboAVI_Change
  284. End Sub
  285. Private Sub cboTimer_Click()
  286.   'If the IE3+ version of COMCTL32.DLL is being used (determined by ComCtlVer),
  287.   'then the control can use a Win32 Timer to synchronise playback rather than
  288.   'a thread which is the default
  289.   On Error Resume Next
  290.   With ccrpAnimation
  291.     .StopPlaying
  292.     .TimerType = cboTimer.ItemData(cboTimer.ListIndex)
  293.     .OpenAVI    'Reopen so changes take effect
  294.   End With
  295. End Sub
  296. Private Sub ccrpAnimation_Click()
  297.   If chkMouseEvents Then AddItemToList "Click"
  298. End Sub
  299. Private Sub ccrpAnimation_DblClick()
  300.   If chkMouseEvents Then AddItemToList "DblClick"
  301. End Sub
  302. Private Sub ccrpAnimation_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  303.   If chkMouseEvents Then AddItemToList "MouseDown: Button = " & Str(Button) & "; Shift = " & Str(Shift) & "; X = " & Str(X) & "; Y = " & Str(Y)
  304. End Sub
  305. Private Sub ccrpAnimation_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  306.   If chkMouseEvents Then AddItemToList "MouseMove: Button = " & Str(Button) & "; Shift = " & Str(Shift) & "; X = " & Str(X) & "; Y = " & Str(Y)
  307. End Sub
  308. Private Sub ccrpAnimation_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  309.   If chkMouseEvents Then AddItemToList "MouseUp: Button = " & Str(Button) & "; Shift = " & Str(Shift) & "; X = " & Str(X) & "; Y = " & Str(Y)
  310. End Sub
  311. Private Sub ccrpAnimation_StatusChanged(OldStatus As Animation.aniStatusConstants, NewStatus As Animation.aniStatusConstants)
  312.   If chkOtherEvents Then AddItemToList "StatusChanged: From " & GetStatusString(OldStatus) & " To " & GetStatusString(NewStatus)
  313.   Select Case NewStatus
  314.     Case aniEmpty
  315.       cmdOpen.Enabled = cboAVI.Text > ""
  316.       cmdPlay.Enabled = cboAVI.Text > ""
  317.     Case aniOpened
  318.       cmdPlay.Caption = "Play"
  319.       cmdPlay.Enabled = True
  320.     Case aniPlaying
  321.       cmdPlay.Caption = "Stop"
  322.       cmdPlay.Enabled = True
  323.     Case aniStopped
  324.       cmdPlay.Caption = "Play"
  325.       cmdPlay.Enabled = True
  326.   End Select
  327. End Sub
  328. Private Sub chkAutoPlay_Click()
  329.   ccrpAnimation.AutoPlay = CBool(chkAutoPlay.Value)
  330. End Sub
  331. Private Sub chkBorder_Click()
  332.   'Sets whether or not a black border is drawn around the control
  333.   ccrpAnimation.BorderStyle = chkBorder.Value
  334. End Sub
  335. Private Sub chkCenter_Click()
  336.   'Centre's the AVI in the control.
  337.   'Have to refresh and reopen AVI to effect changes
  338.   Dim Status As aniStatusConstants
  339.   With ccrpAnimation
  340.     Status = .Status
  341.     .Center = chkCenter.Value
  342.     If Status > aniEmpty Then cmdOpen_Click
  343.     If Status = aniPlaying Then .Play
  344.     .Refresh
  345.   End With
  346. End Sub
  347. Private Sub chkTransparent_Click()
  348.   'If the control is not transparent, the background colour
  349.   'is as defined in the AVI
  350.   Dim Status As aniStatusConstants
  351.   With ccrpAnimation
  352.     Status = .Status
  353.     If chkTransparent.Value = 0 Then .BackStyle = aniOpaque Else .BackStyle = aniTransparent
  354.     If Status > aniEmpty Then cmdOpen_Click
  355.     If Status = aniPlaying Then .Play
  356.   End With
  357. End Sub
  358. Private Sub cmdBrowse_Click()
  359.   cboAVI.Text = OpenFileForAVI
  360. End Sub
  361. Private Sub cmdClearEvents_Click()
  362.   lstEvents.Clear
  363. End Sub
  364. Private Sub cmdOpen_Click()
  365.   On Error GoTo ErrorHandler
  366.   If cboAVI.ListIndex > -1 Then
  367.     ccrpAnimation.OpenStandardAVIResource (cboAVI.ItemData(cboAVI.ListIndex))
  368.   Else
  369.     ccrpAnimation.OpenAVI cboAVI.Text
  370.   End If
  371.   Exit Sub
  372. ErrorHandler:
  373.   MsgBox "Error: " & Str(Err.Number) & " - " & Err.Description
  374.   Resume Next
  375. End Sub
  376. Private Sub cmdPlay_Click()
  377.   On Error Resume Next
  378.   If cmdPlay.Caption = "Play" Then
  379.     ccrpAnimation.Play
  380.   Else
  381.     ccrpAnimation.StopPlaying
  382.   End If
  383. End Sub
  384. Private Sub cmdEnd_Click()
  385.   End
  386. End Sub
  387. Private Sub Form_Load()
  388.   'Neat trick from Karl...
  389.   Set Me.Icon = Nothing
  390.   cboTimer.ListIndex = 0
  391.   cbo3DEffect.ListIndex = 0
  392.   'The ComCtlVer property returns the version of COMCTL32.DLL
  393.   'installed on this machine.
  394.   'If it is not installed, advanced features provided by the
  395.   'updated version will not work but no error will occur
  396.   'ComCtlVer property returns an integer indicating the version currently in use:
  397.   ' 400 - v4.00.950   (supplied with Win95 etc)
  398.   ' 470 - v4.70 (installed with IE3)
  399.   ' 471 - v4.71 (installed with IE4)
  400.   Select Case ccrpAnimation.ComCtlVer
  401.     Case 400
  402.       'Standard Win95 version
  403.       lblInfo.Caption = "COMCTL32.DLL installed on this machine is not updated version. Timer Type option not available"
  404.     Case 470
  405.       'IE3 version
  406.       lblInfo.Caption = "COMCTL32.DLL installed on this machine is IE3 or higher version. Timer Type option available"
  407.       cboTimer.Enabled = True
  408.     Case Is >= 471
  409.       lblInfo.Caption = "COMCTL32.DLL installed on this machine is IE4 or higher version. Timer Type option available"
  410.       cboTimer.Enabled = True
  411.   End Select
  412. End Sub
  413. Private Sub AddItemToList(Item As String)
  414.   With lstEvents
  415.     .AddItem Item
  416.     .ListIndex = .ListCount - 1
  417.   End With
  418. End Sub
  419. Private Function GetStatusString(Status As aniStatusConstants) As String
  420.   Select Case Status
  421.     Case aniEmpty
  422.       GetStatusString = "Empty"
  423.     Case aniOpened
  424.       GetStatusString = "Open"
  425.     Case aniPlaying
  426.       GetStatusString = "Playing"
  427.     Case aniStopped
  428.       GetStatusString = "Stopped"
  429.   End Select
  430. End Function
  431.